package com.eling.elcms.travel.webapp.controller;

import com.eling.elcms.core.dao.hibernate.search.SearchCondition;
import com.eling.elcms.core.webapp.controller.BaseFormController;
import com.eling.elcms.core.webapp.controller.Msg;
import com.eling.elcms.core.webapp.spring.ModelFilling;
import com.eling.elcms.travel.model.AllianceOrg;
import com.eling.elcms.travel.service.IAllianceOrgManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
public class AllianceOrgController extends BaseFormController{

	@Autowired
	private IAllianceOrgManager orgManager;
	
	@RequestMapping("/api/allianceorg/save")
    @ResponseBody
	public AllianceOrg save(@ModelAttribute@ModelFilling AllianceOrg allianceOrg){
		return orgManager.save(allianceOrg);
	}
	
	@RequestMapping("/api/allianceorg/{pkAllianceOrg}/delete")
	@ResponseBody
	public Msg delete(@PathVariable Long pkAllianceOrg){
		orgManager.remove(pkAllianceOrg);
		return new Msg("删除成功");
	}
	
	@RequestMapping("/api/allianceorg/query")
    @ResponseBody
	public List<AllianceOrg> query(@ModelAttribute AllianceOrg allianceOrg){
		return orgManager.query(allianceOrg);
	}
	
	@RequestMapping("/api/allianceorg/search*")
	@ResponseBody
	public List<AllianceOrg> search(@ModelAttribute SearchCondition sc,@ModelAttribute AllianceOrg allianceOrg){
		sc.setQueryCondition(allianceOrg);
		return orgManager.search(sc);
	}
	
	@RequestMapping("/api/allianceorg/saveorg")
    @ResponseBody
	public AllianceOrg saveorg(@ModelAttribute@ModelFilling AllianceOrg allianceOrg){
		return orgManager.saveorg(allianceOrg);
	}//自定义保存方法
}
